/**
 * 文件名称: main.c
 * 摘    要: linux应用程序记录日志测试
 * 来    源: 参考: https://blog.csdn.net/qq_39436605/article/details/81181061
 *
 * 当前版本: 1.0 
 * 作    者: huenrong
 * 完成日期: 2019年06月20日
 **/

#include <stdio.h>
#include <string.h>
#include <unistd.h>

#include "write_log.h"


int main(int argc, char **argv)
{
    int i = 0;
    char log_buf[1024] = {0};

    // 先打印版本相关信息
    printf_log(LOG_INFO, "write_log_demo start\n");

    // snprintf(log_buf, (sizeof(log_buf) - 1), "version [1.1], build time[%s %s].", __DATE__, __TIME__);
    // writo_log_file(LOG_INFO, log_buf);
    writo_log_file(LOG_INFO, "version [1.1], build time[%s %s].", __DATE__, __TIME__);

    // 打印错误log
    printf_log_error("this is error log test\n");
    // snprintf(log_buf, (sizeof(log_buf) - 1), "this is error log info!");
    // writo_log_file(LOG_ERROR, log_buf);
    writo_log_file(LOG_ERROR, "this is error log info!");

    // 打印警告log
    printf_log_warn("this is warn log test\n");
    // snprintf(log_buf, (sizeof(log_buf) - 1), "this is warn log info!");
    // writo_log_file(LOG_WARN, log_buf);
    writo_log_file(LOG_WARN, "this is warn log info!");

    // 打印信息log
    printf_log_info("this is info log test\n");
    // snprintf(log_buf, (sizeof(log_buf) - 1), "this is info log info!");
    // writo_log_file(LOG_INFO, log_buf);
    writo_log_file(LOG_INFO, "this is info log info!");

    while (1)
    {
        // 循环打印调试信息
        printf_log_debug("this is debug log test %d\n", (i));
        // snprintf(log_buf, (sizeof(log_buf) - 1), "this is debug log info!");
        // writo_log_file(LOG_DEBUG, log_buf);
        writo_log_file(LOG_DEBUG, "this is debug log info %d!", i);

        i++;

        sleep(1);
    }

    return 0;
}